import requests
import json

# 创建会话
session = requests.Session()

# 发送目标请求
url = "http://191.254.1.78/msaServiceUrl/taskInfoRestService/selectByConditions"
headers = {
    "Content-Type": "application/json",
    #"Authorization": "Bearer 6a0a7d0f-c768-4121-ae36-5bd87a895e18"
}

cookies = {
}

data = {
'accessToken': "04961185-faab-442f-bbbe-a5add66d9a01",
'pageNum': 1,
'pageSize': 10,
'parameterJson':
"{\"orgId\":\"\",\"isShipType\":\"\",\"taskType\":\"RB_00000006\",\"status\":\"5,8,11\",\"decision\":\"\",\"startTime\":\"2024-10-01 00:00:00\",\"endTime\":\"2024-12-31 23:59:59\",\"startTimeUp\":\"\",\"endTimeUp\":\"\",\"taskGoalName\":\"\",\"taskName\":\"\",\"lawName\":\"\",\"ifSpecial\":\"\",\"deptCode\":\"\",\"taskOrigin\":\"history\"}",
'platform':"PC",
'projectSu': "SZMSA",
"requestSource": "layui"
}

try:
    response = session.post(url, headers=headers, json=data, cookies=cookies)
    response.raise_for_status()  # 检查响应状态码是否为 200
    #print("主表响应内容:", response.json())
    # 响应回来的参数
    strData = json.loads(response.text)
    print("获取响应数据：",strData)
    strRecordsData = strData['datas']['data']  # 获取到具体数据的位置
    print("写一个mysql新建表的语句，表名用为ywtg_ship_xianchangkaixiangjiancha_39，表字段是默认字符串，要避免 Row size too large 错误，并翻译成中文注解插入表，",tuple(strRecordsData[0].keys()))

except requests.exceptions.RequestException as e:
    print(f"请求失败: {e}")
    print("响应内容:", response.text)  # 打印原始响应内容